ssh configuration

last modified

2026–3–17

Passwordless login

On the local machine, create private and public keys:

ssh-keygen

The keys are stored in ~/.ssh as id_rsa and id_rsa.pub. You can choose whether to protect the private key by a passphrase (see below).

Copy the public key onto the remote machine for which you want passwordless ssh:

ssh-copy-id -p <port> <user>@<machine>

On the remote machine, the public keys is added to ~/.ssh/authorized_keys.

You can now login without password – the private key is used instead.

ssh -p <port> <user>@<machine>

However, if you chose to protect the private key by a passphrase, it has to provided upon each login to access the key. To avoid that, run once before:

ssh-add

This prompts for the passphrase and obtains and remembers the private key for further logins.

Aliases

Aliases can be set in ~/.ssh/config. For example, to set dev as an alias for john@dev.example.com -p 2322:

Host dev
    HostName dev.example.com
    User john
    Port 2322